package com.sgolub.commanndsonline.service.entity;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.sgolub.commanndsonline.dao.entity.ProxyUserBasketTotalDAO;
import com.sgolub.commanndsonline.dao.entity.UserBasketDAO;
import com.sgolub.commanndsonline.domain.entity.UserBasket;
import com.sgolub.commanndsonline.domain.proxy.ProxyUserBasketTotal;

@Service
public class UserBasketServiceImpl implements UserBasketService {

	@Autowired
	private UserBasketDAO userBasketDAO;
	
	@Autowired
	private ProxyUserBasketTotalDAO proxyUserBasketTotalDAO;	
	
	@Transactional
	public UserBasket get(Integer id) {
		return userBasketDAO.get(id);
	}

	@Transactional
	public String				checkOneItem (Integer 		id){
		return userBasketDAO.checkOneItem(id);
	}
	
	@Transactional
	public void add(UserBasket userBasket) {
		userBasketDAO.add(userBasket);
	}

	@Transactional
	public void update(UserBasket userBasket) {
		userBasketDAO.update(userBasket);
	}

	@Transactional
	public void remove(Integer id) {
		userBasketDAO.remove(id);
	}

	@Transactional
	public List<UserBasket> list() {
		return userBasketDAO.list();
	}

	@Transactional
	public List<UserBasket> filter() {
		return userBasketDAO.list();
	}

	@Transactional
	public List<UserBasket> listCurrentUserBasket(Integer userId){
		return userBasketDAO.listCurrentUserBasket(userId);
	}

	@Transactional
    public List<UserBasket> advansedListCurrentWithPaginationJQGrid
	(Integer userId,int rowsPerPage, int currentPage, String sortByColumn, String sortMode){
		return userBasketDAO.advansedListCurrentWithPaginationJQGrid(userId, rowsPerPage, currentPage, sortByColumn, sortMode);
	}
	
	@Transactional
	public String clearCurrentUserBasket(Integer userId){
		return userBasketDAO.clearCurrentUserBasket(userId);
	}
	
	@Transactional
	public String addItemToCurrentUserBasket(Integer userId, Integer itemId, Date beginCommandDate){
		return userBasketDAO.addItemToCurrentUserBasket(userId, itemId, beginCommandDate);
	}
	
	@Transactional
	public String submitCurrentUserBasket(Integer userId){
		return userBasketDAO.submitCurrentUserBasket(userId);
	}
	
	@Transactional
    public List<ProxyUserBasketTotal> listByUserId(Integer userId){
		return proxyUserBasketTotalDAO.listByUserId(userId);
	}
	@Transactional
    public Integer totalSumByUserId(Integer userId){
		return proxyUserBasketTotalDAO.totalSumByUserId(userId);
	}
    
	
}
